
from urllib.parse import quote, unquote, quote_plus, unquote_plus

def url_code(string):

    # 编码
    encoded_string = quote(string)
    return encoded_string


def url_code_(input_str):
    # 找到冒号的位置
    colon_index = input_str.index(':')
    # 分别对冒号前后的部分进行编码
    before_colon = input_str[:colon_index]
    after_colon = input_str[colon_index + 1:]
    encoded_before_colon = quote(before_colon)
    encoded_after_colon = quote(after_colon)
    # 组合编码后的结果，保留冒号
    encoded_str = encoded_before_colon + ':' + encoded_after_colon
    return encoded_str


if __name__ == '__main__':
    print(url_code_('{"vmid":"32705"}'))